com.sponsorpay.sdk.android.advertiser
Class SponsorPayAdvertiser

java.lang.Object
  extended by com.sponsorpay.sdk.android.advertiser.SponsorPayAdvertiser
All Implemented Interfaces:
AsyncAPICaller.APIResultListener

public class SponsorPayAdvertiser
extends java.lang.Object
implements AsyncAPICaller.APIResultListener

Provides convenience calls to run the Advertiser callback request. Manages the state of the SDK determining whether a successful response to the callback request has been already received since the application was installed in the host device.

It's implemented as a singleton, and its public methods are static.


Field Summary
static int BUGFIX_RELEASE_NUMBER
           
static int MAJOR_RELEASE_NUMBER
          Version information.
private  AsyncAPICaller mAPICaller
          AsyncAPICaller used to call the Advertiser API asynchronously.
private  Context mContext
          Host app's Android application context.
private  AdvertiserHostInfo mHostInfo
          AdvertiserHostInfo used to collect data related to the host device and application.
static int MINOR_RELEASE_NUMBER
           
private static SponsorPayAdvertiser mInstance
          Singleton instance.
private  SharedPreferences mPrefs
          The shared preferences encoded in the PREFERENCES_FILE_NAME file.
private static java.lang.String PREFERENCES_FILE_NAME
          Shared preferences file name.
private static boolean sShouldUseStagingUrls
           
private static java.lang.String STATE_GOT_SUCCESSFUL_RESPONSE_KEY
          The key to store in the preferences file the flag which determines if we have already successfully contacted the Advertiser API.
static java.lang.String VERSION_STRING
           
 
Constructor Summary
private SponsorPayAdvertiser(Context context)
          Constructor.
 
Method Summary
 void onAPIResponse(boolean wasSuccessful)
          This method is invoked when a response for the advertiser callback is received.
private  void register()
          Calls its overload register() with an empty overrideOfferId parameter.
static void register(Context context)
          Trigger the Advertiser callback.
static void register(Context context, java.lang.String overrideOfferId)
          Trigger the Advertiser callback.
static void registerWithDelay(Context context, int delayMin)
          Trigger the Advertiser callback after the specified delay has passed.
static void registerWithDelay(Context context, int delayMin, java.lang.String overrideOfferId)
          Trigger the Advertiser callback after the specified delay has passed.
static void setShouldUseStagingUrls(boolean value)
           
static boolean shouldUseStagingUrls()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAJOR_RELEASE_NUMBER

public static final int MAJOR_RELEASE_NUMBER
Version information.

See Also:
Constant Field Values

MINOR_RELEASE_NUMBER

public static final int MINOR_RELEASE_NUMBER
See Also:
Constant Field Values

BUGFIX_RELEASE_NUMBER

public static final int BUGFIX_RELEASE_NUMBER
See Also:
Constant Field Values

VERSION_STRING

public static final java.lang.String VERSION_STRING

PREFERENCES_FILE_NAME

private static final java.lang.String PREFERENCES_FILE_NAME
Shared preferences file name. We store a flag into the shared preferences which is checked on each consecutive invocation of register(), to ensure that once we have once successfully contacted the Advertiser API we shall never send the advertiser callback request again (provided the user doesn't uninstall and reinstall the application, or delete all its preferences).

See Also:
Constant Field Values

STATE_GOT_SUCCESSFUL_RESPONSE_KEY

private static final java.lang.String STATE_GOT_SUCCESSFUL_RESPONSE_KEY
The key to store in the preferences file the flag which determines if we have already successfully contacted the Advertiser API.

See Also:
Constant Field Values

mPrefs

private SharedPreferences mPrefs
The shared preferences encoded in the PREFERENCES_FILE_NAME file.


sShouldUseStagingUrls

private static boolean sShouldUseStagingUrls

mHostInfo

private AdvertiserHostInfo mHostInfo
AdvertiserHostInfo used to collect data related to the host device and application.


mAPICaller

private AsyncAPICaller mAPICaller
AsyncAPICaller used to call the Advertiser API asynchronously.


mContext

private Context mContext
Host app's Android application context.


mInstance

private static SponsorPayAdvertiser mInstance
Singleton instance.

Constructor Detail

SponsorPayAdvertiser

private SponsorPayAdvertiser(Context context)
Constructor. Stores the received application context and loads up the shared preferences.

Parameters:
context - The host application context.
Method Detail

setShouldUseStagingUrls

public static void setShouldUseStagingUrls(boolean value)

shouldUseStagingUrls

public static boolean shouldUseStagingUrls()

register

public static void register(Context context)
Trigger the Advertiser callback. Will retrieve the offer ID from the value defined in the host application's Android Manifest XML file.

Parameters:
context - Host application context.

registerWithDelay

public static void registerWithDelay(Context context,
                                     int delayMin)
Trigger the Advertiser callback after the specified delay has passed. Will retrieve the offer ID from the value defined in the host application's Android Manifest XML file.

Parameters:
context - Host application context.
delayMin - The delay in minutes for triggering the Advertiser callback.

registerWithDelay

public static void registerWithDelay(Context context,
                                     int delayMin,
                                     java.lang.String overrideOfferId)
Trigger the Advertiser callback after the specified delay has passed. Will use the provided offer ID instad of trying to retrieve the one defined in the host application's manifest.

Parameters:
context - Host application context.
delayMin - The delay in minutes for triggering the Advertiser callback.
overrideOfferId - The offer id to use.

register

public static void register(Context context,
                            java.lang.String overrideOfferId)
Trigger the Advertiser callback. Will use the provided offer ID instead of retrieving it from the value defined in the host application's Android Manifest XML file.

Parameters:
context - Host application context.
overrideOfferId - The offer id to use.

register

private void register()
Calls its overload register() with an empty overrideOfferId parameter.


onAPIResponse

public void onAPIResponse(boolean wasSuccessful)
This method is invoked when a response for the advertiser callback is received.

Specified by:
onAPIResponse in interface AsyncAPICaller.APIResultListener
Parameters:
wasSuccessful - status flag if the Ad API has been contacted successfully